<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="Adverisarial attack对抗攻击, J Sir">
    <meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>Adverisarial attack对抗攻击 | J Sir</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>

<meta name="generator" content="Hexo 6.0.0">
<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
</head>




<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">J Sir</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">J Sir</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/jy741" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/jy741" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/13.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">Adverisarial attack对抗攻击</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">
                                <span class="chip bg-color">机器学习</span>
                            </a>
                        
                            <a href="/tags/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/">
                                <span class="chip bg-color">深度学习</span>
                            </a>
                        
                            <a href="/tags/%E5%AF%B9%E6%8A%97%E6%94%BB%E5%87%BB/">
                                <span class="chip bg-color">对抗攻击</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2023-02-28
                </div>
                

                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    3.9k
                </div>
                

                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">

        
        <!-- 是否加载使用自带的 prismjs. -->
        <link rel="stylesheet" href="/libs/prism/prism.css">
        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h2 id="奶茶鼠的想法"><a href="#奶茶鼠的想法" class="headerlink" title="奶茶鼠的想法"></a>奶茶鼠的想法</h2><p>留着长长的~头发</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/84c96d390c3c3a7b6e18b6b2c47ab50d6d9a993a.jpg@1036w.webp" alt="img" style="zoom:50%;"></p>
<span id="more"></span>
<h2 id="Introduction"><a href="#Introduction" class="headerlink" title="Introduction"></a>Introduction</h2><h3 id="Concept"><a href="#Concept" class="headerlink" title="Concept"></a>Concept</h3><p>对抗攻击的概念是给正常输入加入特殊的杂讯，形成一个带有攻击性的输入，当其进入模型之后，输出的内容是错误的。被加杂讯的照片叫做 Attacked Image，还没有被加杂讯的照片一般就叫做Benign Image。一般加入的杂讯是很小的，人的肉眼是看不出来的，下图中的攻击图片是夸张了的</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228163206390.png" alt="image-20230228163206390"></p>
<p>实际生活中除了一些正常的噪声，也有一些针对模型的恶意信号，用来骗过模型。而且本来就有一些模型就是为了探测恶意信号，比如恶意邮件，恶意软件等。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228163357944.png" alt="image-20230228163357944"></p>
<h3 id="Classify"><a href="#Classify" class="headerlink" title="Classify"></a>Classify</h3><p>是否知道模型参数</p>
<ul>
<li>白盒攻击（White Box Attack）：已知模型参数</li>
<li>黑盒攻击（Black Box Attack）：未知模型参数</li>
</ul>
<p>是否有攻击得到的目标</p>
<ul>
<li>没有目标的攻击（Non-targeted Attack）：原来的答案是猫，只要你能够让 Network 的输出不是猫就算是成功</li>
<li>有目标的攻击（Targeted Attack）：希望 Network不止它输出不能是猫，还要输出某一指定的别的东西，比如说，把猫错误判断成一隻海星才算是攻击成功。</li>
</ul>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228163546753.png" alt="image-20230228163546753"></p>
<h2 id="White-Box-Attack"><a href="#White-Box-Attack" class="headerlink" title="White Box Attack"></a>White Box Attack</h2><h3 id="How-to-attack"><a href="#How-to-attack" class="headerlink" title="How to attack?"></a>How to attack?</h3><p>Network是一个函数f，输入是一张图片，我们叫它x0，输出是一个 Distribution，分类的结果叫y0。被攻击的模型参数是固定的，攻击者是修改不了模型的，只能修改输入内容X。</p>
<p>如果是 Non-Targeted Attack，要找到一张新的图片x， 经过Network输出是 y，正确的答案叫做 ŷ，希望 y 跟 ŷ 的差距越大越好。loss函数就是y和ŷ的负cross entropy，这一项越小越好，代表 y 跟 ŷ的 Cross Entropy 越大</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228163841721.png" alt="image-20230228163841721" style="zoom:50%;"></p>
<p>如果是Targeted Attack。用$y^{target}$代表目标，ŷ 其实是一个 One-Hot Vector，ytarget也是一个 One-Hot Vector，希望 y 不止跟 ŷ 越远越好，还要跟$y^{target}$越近越好。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/aa880443034f4d789b3c8359dc34ef3a.png" alt="img" style="zoom:67%;"></p>
<h3 id="Non-perceivable"><a href="#Non-perceivable" class="headerlink" title="Non-perceivable"></a>Non-perceivable</h3><p>对于攻击的图片，我们期望加入的杂讯越小越好，也就是新找到的图片跟原来的图片要越相近越好，这样人肉眼才观测不到被攻击了。所以我们在解上面这个Optimization 的 Problem 的时候，还会多加入一个限制 </p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228164429790.png" alt="image-20230228164429790" style="zoom:67%;"></p>
<p>希望 x 跟x0之间的差距小於某一个 Threshold，这个閾值是人类可以感知的极限，如果x0 跟 x 之间的差距大於 $\varepsilon$，人就会发现有一个杂讯存在。让x0 跟 x 的差距小於等於 $\varepsilon$，就可以產生一张图片，人类看起来 x 跟 x0是一模一样的，但產生的结果对 Network 来说是非常不一样的</p>
<p>其中 $d\left(x^{0}, x^{\prime}\right)$通常的定义有两种选择：二范数和无穷范数</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228164820320.png" alt="image-20230228164820320"></p>
<p>第二种方法L∞更加符合人类的感知情况，所以攻击者一般会考虑采用L-infinity。为什么呢？以方块图来说明，右上角的正方形中四个方块都有微小变化，右下角的正方形中只有绿色方块发生变化。并且令两者对原正方形做差，有相同的L2值，但右下角L-∞更大，右上角L-∞比较小，因為 L-∞ 只在意最大的变化量。而从人肉眼观察来看，能明显看出右下角的变化，所以限制最大的差值（L-∞）也许能够更好地将恶意输入伪装成正常输入。</p>
<blockquote>
<p>上面举的例子是影像上的例子，如果要攻击的对象是一个跟语音相关的系统，那什麼样的声音讯号对人类来说听起来有差距，那就不见得是 L2 跟 L-Infinity 了，要研究人类的听觉系统，看看人类对什麼频态的变化特别敏感，根据人类的听觉系统来制定比较适合的 x 跟 x0之间距离的衡量方式，这个部分需要用到 Domain Knowledge</p>
</blockquote>
<h3 id="Attack-approach"><a href="#Attack-approach" class="headerlink" title="Attack approach"></a>Attack approach</h3><p>和以前模型里面的函数不同，之前的是固定输入，调整参数来使loss最小，现在是固定模型参数，调整输入来使loss最小，还是用的梯度下降的方法：将正常的输入x当作初始化值，再迭代更新x，迭代过程是算出loss对输入x的偏微分g，乘上学习率后再更新x。更新完参数以后，如果xt和x的差距大於 ε，就把xt改回符合限制。</p>
<p>假设现在用的是 L-Infinity，那么x 可以存在的范围只有方形框。在更新完x之后，如果x在这个正方形外（蓝色的点），那么就用正方形上最近的点（橙色的点）来替代。</p>
<p>当然，这只是多数方法中的一个，攻击方法可以使用不一样的优化函数，不一样的限制条件，但是本质思想就是这样的。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228165610285.png" alt="image-20230228165610285"></p>
<h3 id="FGSM-Fast-Gradient-Sign-Method"><a href="#FGSM-Fast-Gradient-Sign-Method" class="headerlink" title="FGSM(Fast Gradient Sign Method)"></a>FGSM(Fast Gradient Sign Method)</h3><p>这个方法重点在于只要更新一次x，一击就找出一个可以攻击成功的 Image，不需要迭代多次。</p>
<p>不直接用Gradient Descent 的值，给它取一个 Sign，梯度g的输出只有1和-1两种可能，而学习率设为“感知上限”ε表示，更新一次的x必定会在方框的四个角落上，这个一击往往就可以必杀。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228165832095.png" alt="image-20230228165832095"></p>
<p>Iterative FGSM：假如迭代要多重复几轮，结果会更好，但是x很大概率会跑出方框的范围，这时只要用方框四个角落最近的点来代替即可。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228165950863.png" alt="image-20230228165950863"></p>
<h2 id="Black-Box-Attack"><a href="#Black-Box-Attack" class="headerlink" title="Black Box Attack"></a>Black Box Attack</h2><p>之前的攻击都是White Box（白盒子）的攻击，也就是说我们需要固定网络的参数θ ，才能找到攻击输入$X^*$。那么，如果一个未知结构Black Box的Black模型，该如何进行攻击呢？</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228170151832.png" alt="image-20230228170151832"></p>
<h3 id="Using-Training-Datasets"><a href="#Using-Training-Datasets" class="headerlink" title="Using Training Datasets"></a>Using Training Datasets</h3><p>假设知道这个模型的是由什么数据训练出来的，就可以用这些数据自己训练一个proxy（代理）网络模型。然后用这个代理网络，产生攻击对象$x^<em>$；再把这个攻击对象$x^</em>$拿去攻击原来的Black网络模型。<strong>本质思想就是将黑箱攻击转变成白箱攻击。</strong></p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228170404622.png" alt="image-20230228170404622"></p>
<blockquote>
<p>没有训练资料可以用吗？也可以，没有训练资料的时候，把一堆图片丢进去得到输出，再把输入输出的成对资料拿去训练一个模型，训练出一个类似的模型，当做 Proxy Network 进行攻击。</p>
</blockquote>
<ul>
<li><p>单一攻击</p>
<p>下图的对角线是属于白箱攻击，准确率都为0%，成功率是百分之百。非对角线属于黑箱攻击，比如拿 ResNet-152 当做是 Proxy Network，去攻击 ResNet-50，得到的正确率是 18 %。黑箱攻击模型，最终的正确率比白箱攻击还要高，但是其实这些正确率也都非常低，都是低於 50 %，所以显然黑箱攻击也有一定的成功的可能性。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228170624197.png" alt="image-20230228170624197"></p>
</li>
<li><p>聚合攻击</p>
<p>可以采用Ensemble 的 Network，下图网络前面带上负号意思是proxy不用这个网络而用其余的四个网络来训练，找一个攻击的 Image，在负号网络以外的模型都是成功的，所以对角线是黑箱攻击，非对角线是白箱攻击。可以发现，当找一个 Attacked Image可以成功骗过多个 Network 的时候，骗过一个不知道参数的黑箱的 Network非常容易成功</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228170658421.png" alt="image-20230228170658421"></p>
</li>
</ul>
<h3 id="Why-attack-is-so-easy"><a href="#Why-attack-is-so-easy" class="headerlink" title="Why attack is so easy?"></a>Why attack is so easy?</h3><p>为什么在A网络上攻击成功了，恶意攻击用在B网络上也能成功呢？</p>
<p>下图横轴是在 VGG-16 上面可以攻击成功的方向，纵轴是一个随机的方向，深蓝色的区域是图片会被辨识成小丑鱼的图片的范围。</p>
<p>图片是高维向量，把这个高维向量在高维的空间中往纵轴方向移动（加上一个 Noise），基本上 Network 还是会觉得它是小丑鱼的图片，不管对每一个 Network 来说都是如此。攻击VGG-16成功的方向特别窄，图片往攻击VGG-16 的方向稍微移动一下，其他 Network也有蛮高的机率可以攻击成功。</p>
<p>攻击会成功这件事情不是只有对 Deep Learning 有一样的问题，对 Linear 的 Network、对 SVM 也都有类似的问题。大多数学者认为，攻击会这麼容易成功的原因未必出现在模型上面，可能是出现在资料上。在有限的资料上，机器学到的就是这样子的结论，当我们有足够的资料，也许就有机会避免 Adversarial Attack。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228170743304.png" alt="image-20230228170743304"></p>
<h3 id="Other-attack-approach"><a href="#Other-attack-approach" class="headerlink" title="Other attack approach"></a>Other attack approach</h3><h4 id="one-pixel-attack"><a href="#one-pixel-attack" class="headerlink" title="one pixel attack"></a>one pixel attack</h4><p>只要改动图片的一个像素点，就能使得辨识系统出错。并没有非常地 Powerful</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228170922261.png" alt="image-20230228170922261"></p>
<h4 id="universal-adversarial-attack"><a href="#universal-adversarial-attack" class="headerlink" title="universal adversarial attack"></a>universal adversarial attack</h4><p>用一个 Signal就成功攻击所有的图片。通用恶意攻击，某一个杂讯恶意性强大，不管什麼样的影像都可以攻击成功，都能使辨识系统出错。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228170948286.png" alt="image-20230228170948286"></p>
<h4 id="Speech-Processing"><a href="#Speech-Processing" class="headerlink" title="Speech Processing"></a>Speech Processing</h4><p>一段显然的合成声音讯号加上这个微小的杂讯以后,同一个侦测合成的系统,会觉得刚才那段声音是真实的声音,而不是合成的声音。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228171029709.png" alt="image-20230228171029709"></p>
<h4 id="Natural-Language-Processing"><a href="#Natural-Language-Processing" class="headerlink" title="Natural Language Processing"></a>Natural Language Processing</h4><p>在所有文章末尾贴上,Why How Because To Kill American People,接下来不管你问它什麼问题,它的答案都是 To Kill American People</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228171052229.png" alt="image-20230228171052229"></p>
<h4 id="Attack-Approaches"><a href="#Attack-Approaches" class="headerlink" title="Attack Approaches"></a>Attack Approaches</h4><p>• FGSM ( <a target="_blank" rel="noopener" href="https://arxiv.org/abs/1412.6572">https://arxiv.org/abs/1412.6572</a> )<br>• Basic iterative method ( <a target="_blank" rel="noopener" href="https://arxiv.org/abs/1607.02533">https://arxiv.org/abs/1607.02533</a> )<br>• L-BFGS ( <a target="_blank" rel="noopener" href="https://arxiv.org/abs/1312.6199">https://arxiv.org/abs/1312.6199</a> )<br>• Deepfool ( <a target="_blank" rel="noopener" href="https://arxiv.org/abs/1511.04599">https://arxiv.org/abs/1511.04599</a> )<br>• JSMA ( <a target="_blank" rel="noopener" href="https://arxiv.org/abs/1511.07528">https://arxiv.org/abs/1511.07528</a> )<br>• C&amp;W ( <a target="_blank" rel="noopener" href="https://arxiv.org/abs/1608.04644">https://arxiv.org/abs/1608.04644</a> )<br>• Elastic net attack ( <a target="_blank" rel="noopener" href="https://arxiv.org/abs/1709.04114">https://arxiv.org/abs/1709.04114</a> )<br>• Spatially Transformed ( <a target="_blank" rel="noopener" href="https://arxiv.org/abs/1801.02612">https://arxiv.org/abs/1801.02612</a> )<br>• One Pixel Attack ( <a target="_blank" rel="noopener" href="https://arxiv.org/abs/1710.08864">https://arxiv.org/abs/1710.08864</a> )</p>
<h3 id="Attack-in-Real-world"><a href="#Attack-in-Real-world" class="headerlink" title="Attack in Real world"></a>Attack in Real world</h3><h4 id="Face-recongnition"><a href="#Face-recongnition" class="headerlink" title="Face recongnition"></a>Face recongnition</h4><p>一个男的戴上副眼镜以后，人脸辨识系统就会觉得他是右边这一个知名艺人。攻击人脸辨识系统需要考虑的因素：</p>
<p>1、我们在观看一个东西的时候可以从多个角度去看，考虑三维的各个角度都要能使辨识系统出错。</p>
<p>2、考虑摄像头的解析度极限，如果加入的杂讯太小以至于摄像头解析不出来，那么这个杂讯就等于是白加了。</p>
<p>3、考虑电脑和现实中的色差。印出来后，某一些顏色会偏掉，如果训练出来的眼镜有现实中印不出来的颜色，那么这副眼镜还是起不到攻击作用。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228171251269.png" alt="image-20230228171251269"></p>
<h4 id="Adversarial-Reprogramming"><a href="#Adversarial-Reprogramming" class="headerlink" title="Adversarial Reprogramming"></a>Adversarial Reprogramming</h4><p>我们可以训练一个寄生病毒放入要攻击的网络，让他的判断依据变为我们自己定义的规则。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228171515135.png" alt="image-20230228171515135"></p>
<h3 id="Backdoor-in-Model"><a href="#Backdoor-in-Model" class="headerlink" title="Backdoor in Model"></a>Backdoor in Model</h3><p>对训练资料做手脚，在训练资料裡面加一些看上去正常的图片，而它的标註也都是正常的，拿这个样子的资料进行训练，在测试的阶段就会辨识错误，而且只会对某一张图片辨识错误，对其他的图片还是没有问题，而且这种方式的攻击只对某一特征有问题，而其他东西的分类都是正常的，所以训练结果一般看起来也正常，很难察觉自己被攻击了。所以不要随便用来路不明的训练资料。还是有某一些限制的，并不是说随便什麼模型，随便什麼训练方式，这种开后门的方法都可以攻击成功。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228171553015.png" alt="image-20230228171553015"></p>
<h2 id="Defense"><a href="#Defense" class="headerlink" title="Defense"></a>Defense</h2><p>有人会觉得是会被攻击是因为模型过拟合导致的，但是即使模型使用了weight regularization，dropout等减小过拟合风险的方法依然会被攻击。一般有两种防御手段：</p>
<ul>
<li>Passive Defense（被动防御）：不改变网络模型，只是另外加上一层防御，类似于Anomaly Detection。</li>
<li>Proactive Defense（主动防御）：训练模型的过程中，就要将防御考虑在其中，主要在于要自己找到漏洞并补起来。</li>
</ul>
<h3 id="Passive-Defense"><a href="#Passive-Defense" class="headerlink" title="Passive Defense"></a>Passive Defense</h3><h4 id="Filter"><a href="#Filter" class="headerlink" title="Filter"></a>Filter</h4><p>在输入前加上一个滤波器Filter（例如虚化），可以减轻attack signal 带来的影响：</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228171950710.png" alt="image-20230228171950710"></p>
<p>为什么呢？只有某几个方向的攻击信号是有效的，但是平滑化之后破坏了这个信号，但是平滑又不会对整体影响很大。</p>
<p>副作用：使Confidence分数降低。</p>
<h4 id="Image-Compression"><a href="#Image-Compression" class="headerlink" title="Image Compression"></a>Image Compression</h4><p>比如图片存成 JPEG 档，会造成失真，攻击的讯号受到的影响是比较大，就可以保护你的模型</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228172157722.png" alt="image-20230228172157722"></p>
<h4 id="Generator"><a href="#Generator" class="headerlink" title="Generator"></a>Generator</h4><p>要求 Generator 输出一张图片，这张图片跟输入给Image Classifier 的图片越接近越好，Generator在训练的时候从来没有看过这些杂讯，可能无法復现出这些非常小的杂讯，微小的杂讯就不见了</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228172228236.png" alt="image-20230228172228236"></p>
<h4 id="Randomization"><a href="#Randomization" class="headerlink" title="Randomization"></a>Randomization</h4><p>被动的防御有一个非常大的弱点，假设人家不知道你有用这一招，它就非常有效，一旦人家知道你用什麼招数，那这种被动防御的方法就会瞬间失去效用。比如模糊化这件事等於就是在Network 前面多加了一层，所以假设别人知道你的 Network 前面多加这一层，把多加这一层放到攻击的过程中，它就可以產生一个 Signal，可以躲过模糊化这种防御方式。</p>
<p>还有一种再更强化被动防御的方法就是加上随机性，自己都不知道自己的下一招是什麼，在做这个Defense 的时候啊加上各种不同的 Defense 的方式，比如随机放大缩小图片，随机贴图（贴的位置也是随机的）……</p>
<p>这种随机防御也是有问题，假设你各种随机的可能性都已经被知道的话，那别人只要用 Universal Attacks找一个 Attack 的 Signal 可以攻破所有图片的变化方式的话，Randomization 的方式还是有可能被突破</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228172313853.png" alt="image-20230228172313853"></p>
<h3 id="Proactive-defence"><a href="#Proactive-defence" class="headerlink" title="Proactive defence"></a>Proactive defence</h3><p>主动防御的思想就是训练出一个见多识广的模型，见识过各种各样的攻击。</p>
<p>给一堆训练资料，然后通过攻击算法故意弄坏输入，再将弄坏的输入与正确输出对应上，最后用正常的输入和弄坏的输入一起去训练模型，然后看看这个模型呢有没有什麼漏洞，然后把漏洞填起来，不断地找漏洞，找到就把它填起来。这个方法其实类似于data augmentation（资料增强）</p>
<p>主动防御的缺点：不能挡住新算法的攻击，如果今天攻击你 Model 的方法并没有在 Adversarial Training 的时候被考虑过，那 Adversarial Training也不见得能够挡住新的 Attack 的 Algorithm；需求的资料多，对计算能力要求高。</p>
<p><img src="https://pluto-1300780100.cos.ap-nanjing.myqcloud.com/img/image-20230228172356398.png" alt="image-20230228172356398"></p>
<p>这里为什么有T次循环？因为找出攻击信号，再重新训练模型之后，模型的参数就会改变，那么可能会产生新的漏洞。这个过程要反复多次进行才可以减少漏洞。但是对方如果使用在防守的攻击算法之外的方法，那么这些防守仍然是无效的，所以防守在当前仍然是一个重要研究问题。</p>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">J Sir</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://jy741.gitee.io/2023/02/28/adverisarial-attack-dui-kang-gong-ji/">https://jy741.gitee.io/2023/02/28/adverisarial-attack-dui-kang-gong-ji/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">J Sir</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">
                                    <span class="chip bg-color">机器学习</span>
                                </a>
                            
                                <a href="/tags/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/">
                                    <span class="chip bg-color">深度学习</span>
                                </a>
                            
                                <a href="/tags/%E5%AF%B9%E6%8A%97%E6%94%BB%E5%87%BB/">
                                    <span class="chip bg-color">对抗攻击</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2023/03/01/lun-wen-jing-du-fgsm-explaining-and-harnessing-adversarial-examples/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/14.jpg" class="responsive-img" alt="论文精读：FGSM—EXPLAINING AND HARNESSING ADVERSARIAL EXAMPLES">
                        
                        <span class="card-title">论文精读：FGSM—EXPLAINING AND HARNESSING ADVERSARIAL EXAMPLES</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            奶茶鼠的想法新系列喵~

                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2023-03-01
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            J Sir
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">
                        <span class="chip bg-color">机器学习</span>
                    </a>
                    
                    <a href="/tags/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/">
                        <span class="chip bg-color">深度学习</span>
                    </a>
                    
                    <a href="/tags/%E5%AF%B9%E6%8A%97%E6%94%BB%E5%87%BB/">
                        <span class="chip bg-color">对抗攻击</span>
                    </a>
                    
                    <a href="/tags/%E6%9C%9F%E5%88%8A%E8%AE%BA%E6%96%87/">
                        <span class="chip bg-color">期刊论文</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2023/02/27/explainable-ml-ji-qi-xue-xi-de-ke-jie-shi-xing/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/15.jpg" class="responsive-img" alt="Explainable ML机器学习的可解释性">
                        
                        <span class="card-title">Explainable ML机器学习的可解释性</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            奶茶鼠的想法鼠鼠最近沉迷陶喆的R&amp;B捏~

Introduction机器学习模型，从简单的LR, Decision Tree到复杂的DNN、CNN、RNN、LSTM等， 整体的趋势是模型越来越复杂，模型的可解释性越来越差。
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2023-02-27
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            J Sir
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/">
                        <span class="chip bg-color">机器学习</span>
                    </a>
                    
                    <a href="/tags/%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/">
                        <span class="chip bg-color">深度学习</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h1, h2, h3, h4, h5'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h1, h2, h3, h4, h5').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>


<script src="https://cdn.bootcss.com/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
    MathJax.Hub.Config({
        tex2jax: {inlineMath: [['$', '$'], ['\(', '\)']]}
    });
</script>



    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2020-2023</span>
            
            <span id="year">2020</span>
            <a href="/about" target="_blank">J Sir</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">300.9k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">


    <a href="mailto:2065373132@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=2065373132" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 2065373132" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

	
    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"live2d-widget-model-hibiki"},"display":{"position":"right","width":145,"height":315},"mobile":{"show":true,"scale":0.5},"react":{"opacityDefault":0.7,"opacityOnHover":0.8},"log":false});</script></body>

</html>
